package com.apes.hr.base.repository;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.apes.framework.query.ApesDao;
import org.springframework.stereotype.Component;

/**
 * @program:
 * @description:
 * @author: lws
 * @create: 2023/2/16 11:38
 **/
@Component
public class EmployeeDao extends ApesDao {

    /**
     * 根据部门查询岗位（店长助理，服务顾问）的在职员工
     * -入参:deptId
     * @return
     */
    public JSONArray partyRoleByPostAndDeptId(JSONObject param) {
        String sql = " SELECT (\n" +
                "            SELECT N.ID\n" +
                "            FROM MAS_PARTY M,\n" +
                "                 MAS_PARTY_ROLE N\n" +
                "            WHERE M.ID = N.PARTY_ID\n" +
                "              AND M.NAME = A.NAME\n" +
                "              AND N.ROLE_ID = 'Employee'\n" +
                "        ) PARTY_ROLE_ID\n" +
                " FROM HR_EMPLOYEE A\n" +
                " WHERE A.WORK_BRANCH_ID = :deptId\n" +
                " AND A.POST_ID IN ('0000010', '0000009')\n" +
                " AND A.EMPLOYEE_STATE_ID = '000088' ";
        return toJSONArray(find(sql,param));
    }
}
